package com.sailorj.service.impl;

import com.sailorj.entity.SysLog;
import com.sailorj.mapper.SysLogMapper;
import com.sailorj.service.SysLogService;
import com.sailorj.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysLogServiceImpl implements SysLogService {

    @Autowired
    public SysLogMapper sysLogMapper;

    @Override
    public int addSysLog(SysLog sysLog) {
        return  sysLogMapper.insert(sysLog);
    }

    @Override
    public SysLog getSysLogById(int id) {
        return sysLogMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageBean getSysLogList(Integer page, Integer size) {
        if(page!=null&&size!=null){
            page=(page-1)*size;
        }
        List<SysLog> data = sysLogMapper.getSysLogList(page,size);
        Long total=sysLogMapper.getTotal();
        PageBean bean = new PageBean();
        bean.setData(data);
        bean.setTotal(total);
        return bean;
    }
}
